/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.rantipin.utilities;

import java.awt.LayoutManager;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;

/**
 *
 * @author rantipin
 */
public class TaskPaneBuilder {
    
    private JXTaskPaneContainer getContainer() {
        if (container == null) {
            container = new JXTaskPaneContainer();
        }
        return container;
    }
    
    public void setLayout(LayoutManager mgr) {
        getContainer().setLayout(mgr);
    }
    
    public void addJXPanel(String title, JPanel panel, boolean expand, LayoutManager mgr) {
        JXTaskPane taskPane = new JXTaskPane();
        taskPane.setLayout(mgr);
        taskPane.setExpanded(expand);
        taskPane.setTitle(title);
        taskPane.add(panel);
        getContainer().add(taskPane);
    } 
    
    public JScrollPane createJXTaskPanel() {
        return new JScrollPane(getContainer());
    }
    
    private JXTaskPaneContainer container = null;
}
